﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package L10n.LocaleSettings {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import __AS3__.vec.*;
    import flash.text.*;
    import org.aswing.border.*;
    import flash.system.*;
    import flash.net.*;
    import L10n.*;
    import L10n.sns.*;

    public class LocaleSetting extends EventDispatcher {

        public static const FONT_ASSET_LOADED:String = "font_asset_loaded";

        protected var default_font_name:String = "";
        protected var default_font_name_bold:String = "";
        protected var title_font:String = "";
        protected var default_serif_font:String = "";
        protected var system_font_fallback:Array;
        protected var selected_font:String = "";
        protected var fontFallbackOrderList:Vector.<String>;
        protected var availableFontsList:Dictionary;
        protected var proxyClassDict:Dictionary;
        public var sns:LocaleSNS;
        public var genericMessageMargin:Number = 0;

        public function LocaleSetting(_arg1:String){
            this.availableFontsList = new Dictionary();
            this.proxyClassDict = new Dictionary();
            super();
            switch (_arg1){
                case LocaleHelper.SNS_FACEBOOK:
                    this.sns = new LocaleSNS_FaceBook();
                    break;
                case LocaleHelper.SNS_PENGYOU:
                    this.sns = new LocaleSNS_PengYou();
                    break;
                default:
                    this.sns = new LocaleSNS_FaceBook();
            };
        }
        public function get DEFAULT_FONT_NAME():String{
            return (this.default_font_name);
        }
        public function get DEFAULT_FONT_NAME_BOLD():String{
            return (this.default_font_name_bold);
        }
        public function get TITLE_FONT():String{
            return (this.title_font);
        }
        public function get DEFAULT_SERIF_FONT():String{
            return (this.default_serif_font);
        }
        public function get SYSTEM_FONT():String{
            var _local1:uint;
            var _local2:String;
            if (this.selected_font == ""){
                this.selected_font = "_sans";
                if (this.system_font_fallback){
                    _local1 = 0;
                    while (_local1 < this.system_font_fallback.length) {
                        _local2 = (this.system_font_fallback[_local1] as String);
                        if (this.availableFontsList[_local2]){
                            this.selected_font = _local2;
                            break;
                        };
                        _local1++;
                    };
                };
                return (this.selected_font);
            };
            return (this.selected_font);
        }
        public function generateObject(_arg1:Class, ... _args):Object{
            return (new (_arg1)());
        }
        public function loadFontAsset():void{
            this.loadFontAssetComplete();
        }
        protected function loadExternalFontAsset(_arg1:String):void{
            var _local2:String = Global.getAssetURL(_arg1);
            var _local3:URLLoader = new URLLoader();
            _local3.dataFormat = URLLoaderDataFormat.BINARY;
            _local3.addEventListener(Event.COMPLETE, this.onBytesComplete);
            _local3.load(new URLRequest(AssetUrlManager.instance.lookUpUrl(_local2)));
        }
        private function onBytesComplete(_arg1:Event):void{
            var _local2:ByteArray = (_arg1.target as URLLoader).data;
            var _local3:Loader = new Loader();
            var _local4:LoaderContext = new LoaderContext();
            _local4.applicationDomain = ApplicationDomain.currentDomain;
            _local3.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onLocaleFontLoaded);
            _local3.loadBytes(_local2, _local4);
        }
        private function onLocaleFontLoaded(_arg1:Event):void{
            (_arg1.currentTarget as LoaderInfo).removeEventListener(Event.COMPLETE, this.onLocaleFontLoaded);
            this.loadFontAssetComplete();
        }
        private function loadFontAssetComplete():void{
            var _local1:Array = Font.enumerateFonts(true);
            var _local2:uint;
            while (_local2 < _local1.length) {
                this.availableFontsList[(_local1[_local2] as Font).fontName] = true;
                _local2++;
            };
            this.dispatchEvent(new Event(FONT_ASSET_LOADED));
        }
        public function doAction():Boolean{
            return (false);
        }
        public function TextField_adjust(_arg1:TextField, _arg2:Object):void{
            if (!this.doAction()){
                return;
            };
            this.adjustTextField(_arg1, _arg2);
        }
        protected function adjustTextField(_arg1:TextField, _arg2:Object):void{
            var _local3:TextFormat = _arg1.getTextFormat();
            if (_local3 == null){
                _local3 = new TextFormat();
            };
            if (_arg2.hasOwnProperty("size")){
                _local3.size = _arg2.size;
            };
            if (_arg2.hasOwnProperty("letterSpacing")){
                _local3.letterSpacing = _arg2.letterSpacing;
            };
            if (_arg2.hasOwnProperty("font")){
                _local3.font = _arg2.font;
            };
            if (_arg2.hasOwnProperty("leading")){
                _local3.leading = _arg2.leading;
            };
            if (_arg2.hasOwnProperty("align")){
                _local3.align = _arg2.align;
            };
            if (_arg2.hasOwnProperty("color")){
                _local3.color = _arg2.color;
            };
            if (_arg2.hasOwnProperty("bold")){
                _local3.bold = _arg2.bold;
            };
            _arg1.setTextFormat(_local3);
            _arg1.defaultTextFormat = _local3;
            if (_arg2.hasOwnProperty("x")){
                _arg1.x = _arg2.x;
            };
            if (_arg2.hasOwnProperty("y")){
                _arg1.y = _arg2.y;
            };
            if (_arg2.hasOwnProperty("width")){
                _arg1.width = _arg2.width;
            };
            if (_arg2.hasOwnProperty("height")){
                _arg1.height = _arg2.height;
            };
            if (_arg2.hasOwnProperty("embedFonts")){
                _arg1.embedFonts = _arg2.embedFonts;
            };
            if (_arg2.hasOwnProperty("autoSize")){
                _arg1.autoSize = _arg2.autoSize;
            };
            if (_arg2.hasOwnProperty("text")){
                _arg1.text = _arg2.text;
            };
        }
        protected function adjustCompoentMargin(_arg1:Component, _arg2:Object):void{
            var _local3:Number = 0;
            var _local4:Number = 0;
            if (_arg2.hasOwnProperty("topMargin")){
                _local3 = _arg2.topMargin;
            };
            if (_arg2.hasOwnProperty("bottomMargin")){
                _local4 = _arg2.bottomMargin;
            };
            _arg1.setBorder(new EmptyBorder(null, new Insets(_local3, 0, _local4, 0)));
        }
        public function TextField_applyTextFormat(_arg1:TextField, _arg2:TextFormat):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setTextFormat(_arg2);
            _arg1.defaultTextFormat = _arg2;
        }
        public function DisplayObject_adjust(_arg1:DisplayObject, _arg2:Object):void{
            if (!this.doAction()){
                return;
            };
            this.copyProperties(_arg2, _arg1);
        }
        public function Number_adjust(_arg1:Number, _arg2:Number):Number{
            if (!this.doAction()){
                return (_arg1);
            };
            return (_arg2);
        }
        public function ASwingHelper_setEasyBorder(_arg1:Component, _arg2:Number, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setBorder(new EmptyBorder(null, new Insets(_arg2, _arg3, _arg4, _arg5)));
        }
        public function ASwingHelper_setPreferredHeight(_arg1:Component, _arg2:int):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setPreferredHeight(_arg2);
        }
        public function ASwingHelper_setPreferredWidth(_arg1:Component, _arg2:int):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setPreferredWidth(_arg2);
        }
        public function JLabel_setFont(_arg1:JLabel, _arg2:String, _arg3:uint):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setFont(new ASFont(_arg2, _arg3));
        }
        public function JLabel_setForeground(_arg1:JLabel, _arg2:uint):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setForeground(new ASColor(_arg2));
        }
        public function bypassCharactersToNum(_arg1:String, _arg2:uint):String{
            if (!this.doAction()){
                return (_arg1);
            };
            if (((_arg1) && ((_arg1.length > _arg2)))){
                return ((_arg1.substr(0, (_arg2 - 1)) + "…"));
            };
            return (_arg1);
        }
        public function matchFontAdjust_SIM_HEI(_arg1:Component, _arg2:Object):void{
        }
        private function copyProperties(_arg1:Object, _arg2:Object):void{
            var _local3:String;
            for (_local3 in _arg1) {
                if (_arg2.hasOwnProperty(_local3)){
                    _arg2[_local3] = _arg1[_local3];
                };
            };
        }
        public function GenericDialog_setMessageUGC(_arg1:GenericDialog, _arg2:Boolean):void{
            if (!this.doAction()){
                return;
            };
            _arg1.setMessageUGC(_arg2);
        }

    }
}//package L10n.LocaleSettings 
